/**
 * Project: complex.jetty
 * 
 * File Created at 2010-6-30
 * $Id$
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.complex.jetty;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

/**
 * @description:启动jetty
 * 访问地址:http://localhost:8089/test
 * @author gaoliang
 * @date 2010-6-30
 * @version 1.0
 */
public class StartJetty {
    public static void main(String[] args) {
        //定义server  端口为8089
        Server server = new Server(8089);
        //定义上下文
        Context root = new Context(server, "/", Context.SESSIONS);
        //初始化一个servlet
        TestServlet servlet = new TestServlet();
        //将servlet加入到上下文 path:/test
        root.addServlet(new ServletHolder(servlet), "/test");

        try {
            //启动jetty
            server.start();
            //server.stop();关闭jetty
            System.out.println("start success");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
